//
//  PayBackRecordInfo.m
//  HxgProject
//
//  Created by 黄小刚 on 2018/7/15.
//  Copyright © 2018年 XMYY-19. All rights reserved.
//

#import "PayBackRecordInfo.h"

@implementation PayBackRecordInfo


- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"loanPackage"]) {
        // 赋值
        self.repaymentNum = value;
    }
    
    if ([key isEqualToString:@"loanperiod"]) {
        //
        self.curRepaymentPeriod = @"7天";
    }
    
    if ([key isEqualToString:@"overdueFlag"]) {
        self.isOverTime = [self getOverTimeStr:value];
    }
    
    if ([key isEqualToString:@"loanOperation"]) {
        self.curRepayStatus = [self getRepaymentStatusStr:value];
    }
    
    //    // 过滤状态字段
    //    if ([key isEqualToString:@"children"]) {
    //        NSArray *childArrs = (NSArray *)value;
    //
    //        int loanOperationInt = -1;
    //        NSDictionary *tempDic = nil;
    //        for (NSDictionary *dic in childArrs) {
    //
    //            int tempLoanOperation = 0;
    //            if (!isEmptyString(dic[@"loanOperation"])) {
    //                tempLoanOperation = [dic[@"loanOperation"] intValue];
    //            }
    //
    //            if (tempLoanOperation > loanOperationInt) {
    //                loanOperationInt = tempLoanOperation;
    //                tempDic = dic;
    //            }
    //        }
    //    }
}

- (NSString *)getOverTimeStr:(NSString *)str{
    NSString *returnStr = @"否";
    if ([str isEqualToString:@"Y"]) {
        returnStr = @"是";
    }
    return returnStr;
}

- (NSString *)getRepaymentStatusStr:(NSString *)loanOperationStr {
    NSString *stateStr = @"待审核";
    if ([loanOperationStr isEqualToString:@"4"]) {
        stateStr = @"已逾期";
    } else if ([loanOperationStr isEqualToString:@"3"]) {
        stateStr = @"已结束";
    }else if ([loanOperationStr isEqualToString:@"2"]) {
        stateStr = @"已通过";
    } else if ([loanOperationStr isEqualToString:@"1"]) {
        stateStr = @"待审核";
    }
    
    return stateStr;
}

@end
